<?php /* Smarty version 2.6.26, created on 2011-02-27 07:00:46
         compiled from admin/product_cate_manage.html */ ?>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "admin/header.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
<div class="container">
	<div class="floattop">
		<div class="itemtitle">
			<h3>产品类别管理</h3>
			<ul class="tab1">
				<li><a href="product_cate_manage.php"><span>类别列表</span></a></li>
				<li><a href="?act=show_add_form"><span>添加类别</span></a></li>
			</ul>
		</div>
	</div>
	<div class="floattopempty"></div>

	<?php if ($this->_tpl_vars['show_add_form']): ?>
		<form id="formadd" action="?act=add" method="post">
			<table class="tb tb2">
				<tbody>
					<tr>
						<td class="td27" colspan="2">类别名称：</td>
					</tr>
					<tr class="noborder">
						<td class="vtop rowform">
							<input class="txt" type="text" value="" name="cate_name">
						</td>
						<td class="vtop tips2"></td>
					</tr>
					<tr>
						<td colspan="15">
							<input class="btn" type="submit" value="提交">
						</td>
					</tr>
				</tbody>
			</table>
		</form>
	<?php elseif ($this->_tpl_vars['show_edit_form']): ?>
		<form id="formedit" action="?act=save" method="post">
			<table class="tb tb2">
				<tbody>
					<tr>
						<td class="td27" colspan="2">类别名称：</td>
					</tr>
					<tr class="noborder">
						<td class="vtop rowform">
							<input class="txt" type="text" value="<?php echo $this->_tpl_vars['categorys']['cate_name']; ?>
" name="cate_name">
						</td>
						<td class="vtop tips2"></td>
					</tr>
					<tr>
						<td colspan="15">
							<input class="btn" type="submit" value="保存">
						</td>
					</tr>
				</tbody>
			</table>
			<input type="hidden" name="cate_id" value="<?php echo $this->_tpl_vars['categorys']['cate_id']; ?>
">
			<input type="hidden" name="o_cate_name" id="o_cate_name" value="<?php echo $this->_tpl_vars['categorys']['cate_name']; ?>
">
		</form>		
	<?php else: ?>
		<div class="list-div">
		<table class="tb tb2" cellspacing="1" cellpadding="3">
			<tbody>
				<tr class="header">
					<th>编号</th>
					<th>类别名称</th>
					<th>操作</th>
				</tr>
				<?php $_from = $this->_tpl_vars['cate_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['cl']):
?>
				<tr class="td-cls">
					<td><?php echo $this->_tpl_vars['cl']['cate_id']; ?>
</td>
					<td><?php echo $this->_tpl_vars['cl']['cate_name']; ?>
</td>
					<td><span class="operation"><a href="?act=edit&cate_id=<?php echo $this->_tpl_vars['cl']['cate_id']; ?>
">编辑</a></span><span class="operation"><a href="#" class="del">删除</a></span></td>
				</tr>
				<?php endforeach; endif; unset($_from); ?>	
			</tbody>
		</table>
		</div>	
	<?php endif; ?>
</div>
<script type="text/javascript">
$(document).ready(function(){
	$('#formadd, #formedit').validate({
		rules: {
			cate_name: {
				required: true,
				remote: {
					url:'product_cate_manage.php',
					data: {
						act:'checkExist',
						o_cate_name:function(){return $("#o_cate_name").val()}
					}
				}
			}
		},
		messages: {
			cate_name: {required: '请输入类别名称',remote:'类别名称已存在'}
		},
		success:function(label) { 
			label.html(" ").addClass("right");
		}
		
	});
});

$(".del").click(function(){
	if(confirm('确认删除？')) {
		var obj = $(this);
		var $cate_id = obj.parents('tr').find('td').eq(0).text();
		$.get('product_cate_manage.php', {act:'del', cate_id:$cate_id}, function(data){ 
			if(data == 1) {
				alert('删除成功');
				obj.parents('tr').remove();	
			}
			if(data == 0) {
				alert('此类别下存在数据，不能删除！');
			}
		});
	}
});

</script>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "admin/footer.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
